#include <stdio.h>
#include<stdbool.h>

int max(int num1, int num2) 
{
   /* 局部变量声明 */
    int result;
    if (num1 > num2)
        result = num1;
    else
        result = num2;
    return result; 
}

int massage(int *nums,int length) 
{
    if(length == 0)
            return 0;
        if(length == 1)
        {
            return nums[0];
        }
        if(length == 2)
            return max(nums[0],nums[1]);
        //核心代码
        int minus2 = nums[0];
        int minus1 = max(nums[0],nums[1]);
        int cur = 0;
        for(int i = 2;i<length;++i) 
        {
            cur = max(minus1,minus2 + nums[i]);
            minus2 = minus1;
            minus1 = cur;
        }
        return cur;
    }

int main()
{
    int nums[10];
    int temp;
    int k=0;
    while(true)//input
    {
        scanf("%d",&temp);
        if(temp == 0) break;
        nums[k++] = temp;
    }
    // for (int j=0;j < k; j++)
    // {
    //     printf("%d\n",nums[j]);
    // }
    int result = massage(nums,k);
    printf("%d\n",result);
    return 0;
}